package com.example.farmeri.ui.strategy;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;

import com.example.farmeri.R;
import com.example.farmeri.pojo.Role;
import com.example.farmeri.pojo.vo.BaseCallBack;
import com.example.farmeri.presenter.strategy.AddStrategyPresenter;
import com.example.farmeri.presenter.strategy.IAddStrategyContract;
import com.example.farmeri.ui.base.BaseActivity;

import butterknife.ButterKnife;

public class AddStrategyActivity extends BaseActivity<AddStrategyPresenter> implements IAddStrategyContract {

    private AlertDialog dialog;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_strategy);
        ButterKnife.bind(this);
        initToolBar(R.id.add_strategy_toolbar,"添加策略",true,true);
        initDialog();
        init();
    }

    private void init() {
        present = new AddStrategyPresenter(this);
    }

    private void initDialog() {
        dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("提示");
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "添加成功", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });

    }


    public void btn_add(View view) {
        String id = getIntent().getStringExtra("id");
        //dialog.show();
        if (id == null){
            Log.e("TAG", "btn_add: id is null" );
            return;
        }
//        present.getRole(id);
    }


    @Override
    public void onRoleDataResult(Role data) {
        dialog.show();
    }

    @Override
    public void onRoleDataError(String msg) {
        showMessage(msg);
    }

    @Override
    public void showMessage(String msg) {
        showToast(msg);
    }
}
